﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 客户端
{
    public partial class 修改密码 : Form
    {
        public static string id;
        public 修改密码()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string pass1 = textBox1.Text;
            string pass2 = textBox2.Text;
            string constr = login.constr;
            SqlConnection con = new SqlConnection(constr);
            // 打开连接
            con.Open();
            // 指定SQL语句

            SqlCommand COM = new SqlCommand("select Caccount from Customer where Caccount=" + id + " and Cpassword =" + pass1 + "", con);
            SqlDataAdapter da = new SqlDataAdapter(COM);
            DataSet ds = new DataSet();

            int n = da.Fill(ds, "修改客户密码");

            if (n != 0)
            {
                SqlCommand com = new SqlCommand("update Customer set Cpassword =" + pass2 + " where Caccount ='" + id + "'", con);
                SqlDataReader sdr = com.ExecuteReader();
                MessageBox.Show("修改成功", "提示");
            }
            else
            {
                MessageBox.Show("密码错误", "提示");
                this.Hide();
                return;

            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
